﻿namespace QiangPiao
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    using SQ.Base;

    public class FrmCheckAuthorize : Form
    {
        private Button btnCancel;
        private Button btnReg;
        private IContainer components = null;
        private Label label1;
        private TextBox txtAuthorize;

        public FrmCheckAuthorize()
        {
            this.InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //string diskID = PublicInfo.GetDiskID();
                //if (diskID == "unknow")
                //{
                //    MessageBox.Show("本机无法完成注册，请联系作者！", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                //}
                //else
                //{
                //    AuthorizeInfo info = PublicInfo.Proxy.Authorize(this.txtAuthorize.Text, null, diskID);
                //    if ((info != null) && PublicInfo.CheckAuthorizeInfo(info))
                //    {
                //        if (PublicInfo.WriteAuthorizeInfo(info))
                //        {
                //            MessageBox.Show(string.Format("注册成功，当日可预定车票数量[{0}]，{1}使用暴力模式！", info.AuthorizeTimes, (info.ForceTimes > 1) ? "可" : "不可"), "提醒", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //            base.Close();
                //        }
                //        else
                //        {
                //            MessageBox.Show("注册信息写入失败，请联系作者！", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                //        }
                //    }
                //    else
                //    {
                //        MessageBox.Show("注册失败，请验证注册码后重试！", "警告", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                //    }
                //}
            }
            catch (Exception exception)
            {
                MessageBox.Show("注册时发生错误！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                Log.WriteLog4Ex("FrmCheckAuthorize.btnOK_Click", exception);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmCheckAuthorize_Load(object sender, EventArgs e)
        {
            //if (PublicInfo.AuthorizeInfo != null)
            //{
            //    this.txtAuthorize.Text = PublicInfo.AuthorizeInfo.Authorize;
            //}
        }

        private void InitializeComponent()
        {
            this.label1 = new Label();
            this.txtAuthorize = new TextBox();
            this.btnReg = new Button();
            this.btnCancel = new Button();
            base.SuspendLayout();
            this.label1.AutoSize = true;
            this.label1.Location = new Point(12, 15);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x2f, 12);
            this.label1.TabIndex = 0;
            this.label1.Text = "授权码:";
            this.txtAuthorize.Location = new Point(0x59, 12);
            this.txtAuthorize.Name = "txtAuthorize";
            this.txtAuthorize.Size = new Size(0x100, 0x15);
            this.txtAuthorize.TabIndex = 0;
            this.btnReg.Location = new Point(110, 0x27);
            this.btnReg.Name = "btnReg";
            this.btnReg.Size = new Size(0x4b, 0x17);
            this.btnReg.TabIndex = 2;
            this.btnReg.Text = "注册";
            this.btnReg.UseVisualStyleBackColor = true;
            this.btnReg.Click += new EventHandler(this.btnOK_Click);
            this.btnCancel.Location = new Point(0xf9, 0x27);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new Size(0x4b, 0x17);
            this.btnCancel.TabIndex = 3;
            this.btnCancel.Text = "取消";
            this.btnCancel.UseVisualStyleBackColor = true;
            this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
            base.AcceptButton = this.btnReg;
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            //base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(360, 0x45);
            base.Controls.Add(this.btnCancel);
            base.Controls.Add(this.btnReg);
            base.Controls.Add(this.txtAuthorize);
            base.Controls.Add(this.label1);
            base.FormBorderStyle = FormBorderStyle.SizableToolWindow;
            base.Name = "FrmCheckAuthorize";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "授权";
            base.TopMost = true;
            base.Load += new EventHandler(this.FrmCheckAuthorize_Load);
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

